<!DOCTYPE html>
<html>
<head>
  <title>文字转语音</title>
</head>
<body>
  <input type="text" id="inputText" placeholder="输入要转换为语音的文本">
  <button onclick="speakText()">转换为语音</button>

  <script>
    function speakText() {
      const text = document.getElementById('inputText').value;
      const utterance = new SpeechSynthesisUtterance(text);
      window.speechSynthesis.speak(utterance);
    }
  </script>
</body>
</html>